package com.zhiying.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import com.zhiying.domain.CMS_User;
import com.zhiying.domain.User;

@Transactional
public interface ReLogin extends JpaRepository<CMS_User,Long>  {
	

	@Query("from User where name like CONCAT('%',:name,'%') and password like CONCAT('%',:pwd,'%')")
	List<User> getUser(Pageable pageable,@Param("name") String name,@Param("pwd") int password);
	
	@Query("from CMS_User where loginName=:loginName and loginPassword=:loginPassword")
	CMS_User getUserInfoByByPasswordandUser(@Param("loginName") String loginname,@Param("loginPassword") String password);
	/* 根据用户名和密码获取用户信息 */
	@Query(value= "select * from cms_user as user,cms_organization as organization where"
			+ " organization.organization_id=user.organization_id and "
			+ "user.login_name=:loginName",nativeQuery = true)
	CMS_User getUserInfoByUserName(@Param("loginName") String loginname);
	/* 根据用户名称获取用户信息 */
}
